<template>
	<view class="mine tn-safe-area-inset-bottom">

		<!-- 顶部自定义导航 -->
		<tn-nav-bar :isBack="false" :bottomShadow="false" backgroundColor="none">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left" @click="tn('/minePages/set')">
				<view class="custom-nav__back">
					<view class="tn-icon-set tn-color-cat" style="font-size: 50rpx;">
						<!-- <tn-badge backgroundColor="#E72F8C" fontColor="#FFFFFF" :absolute="true" :translateCenter="false">
              <text>12</text>
            </tn-badge> -->
					</view>
				</view>
			</view>
		</tn-nav-bar>

		<view class="top-backgroup">
			<image src='https://resource.tuniaokj.com/images/my/my-bg4.png' mode='widthFix' class='backgroud-image'>
			</image>
		</view>

		<view class="about__wrap" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
			<!-- 图标logo/头像 -->
			<view class="tn-flex tn-flex-row-between tn-flex-col-center tn-margin-bottom" style="margin-top: -450rpx;"
				@click="tn('/minePages/set')">
				<view class="justify-content-item">
					<view class="tn-flex tn-flex-col-center tn-flex-row-left">
						<view class="logo-pic tn-shadow">
							<view class="logo-image">
								<view class="tn-shadow-blur"
									:style="{backgroundImage:'url('+user.avatar+');width: 110rpx;height: 110rpx;background-size: cover;'}">
								</view>
							</view>
						</view>
						<view class="tn-padding-right">
							<view class="tn-padding-right tn-padding-left-sm">
								<text class="tn-color-cat tn-text-xl tn-text-bold">{{user.nickName}}</text>
								<!-- <text class=" tn-round tn-text-xs tn-bg-red tn-color-white tn-margin-left-sm" style="padding: 10rpx 20rpx;" @click="tn('/minePages/realname')">
                  未实名
                </text> -->
							</view>
							<view class="tn-padding-right tn-padding-top-xs tn-padding-left-sm tn-text-ellipsis">
								<text class="tn-color-gray">ID: {{user.newUserId}}</text>
							</view>
						</view>

					</view>
				</view>
				<view class="justify-content-item">
					<view class="tn-icon-right tn-color-gray">
					</view>
				</view>
			</view>

			<!-- 没有授权，则显示这个授权按钮-->
			<!-- <view class="tn-flex tn-flex-row-between" @click="tn('/minePages/login')">
        <view class="tn-flex-1 justify-content-item tn-margin-xs tn-text-center">
          <tn-button shape="round" backgroundColor="#1D2541" fontColor="#ffffff" padding="20rpx 0" width="40%" shadow>
            <text class="tn-icon-wechat tn-padding-right-xs tn-text-xl"></text>
            <text class="">授权登录</text>
          </tn-button>
        </view>
      </view> -->

			<view class="tn-margin-top-xl" @click="tn('/minePages/recharge')">
				<view class="button-vip tn-flex tn-flex-row-between tn-flex-col-center tn-shadow-blur"
					style="background: linear-gradient(-120deg, #3E445A, #31374A, #2B3042, #262B3C);">

					<view class="tn-margin-left">
						<view class='title'>
							<text class="tn-text-bold tn-text-xl" style="color: #F1C68E;">￥{{wallet.yuE}}</text>
							<!-- <text class="tn-icon-vip-text tn-text-center" style="position: absolute;margin: -22rpx 0 0 0;font-size: 92rpx;"></text> -->
						</view>
						<view class='tn-color-white tn-text-sm tn-padding-top-sm'></view>
					</view>
					<view class="tn-margin-right">
						<!-- <tn-button shape="round" backgroundColor="#F1C68E" fontColor="#634738" padding="10rpx 0" width="160rpx" shadow open-type="share"> -->
						<tn-button backgroundColor="#F1C68E" fontColor="#634738" padding="10rpx 0" width="160rpx">
							<!-- <text class="tn-icon-vip tn-padding-right-sm tn-text-lg"></text> -->
							<text class="tn-text-bold">充 值</text>
						</tn-button>
					</view>

				</view>
			</view>

			<!-- 方式15 start-->
			<view class="tn-flex tn-flex-row-between tn-bg-white about-shadow tn-margin-top-xl">
				<view class="tn-padding-sm tn-margin-xs" @click="tn('/orderPages/mySendOrder')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center tn-margin-left">
						<view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur"
							style="background-color: #F3F2F7;color: #7C8191;">
							<view class="tn-icon-discover"></view>
						</view>
						<view class="tn-text-center">
							<text class="tn-text-ellipsis">发布</text>
						</view>
					</view>
				</view>
				<view class="tn-padding-sm tn-margin-xs" @click="tn('/orderPages/myTakeOrder')">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
						<view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur"
							style="background-color: #F3F2F7;color: #7C8191;">
							<view class="tn-icon-topics"></view>
						</view>
						<view class="tn-text-center">
							<text class="tn-text-ellipsis">接手</text>
						</view>
					</view>
				</view>
				<view class="tn-padding-sm tn-margin-xs" @click="tn('/minePages/withdraw')">
					<view
						class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center tn-margin-right">
						<view class="icon15__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur"
							style="background-color: #F3F2F7;color: #7C8191;">
							<view class="tn-icon-money"></view>
						</view>
						<view class="tn-text-center">
							<text class="tn-text-ellipsis">钱包</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 方式15 end-->


			<!-- 方式20 start-->
			<!-- <view class="tn-flex">
        <view class="tn-flex-1 about-shadow tn-bg-white" style="margin: 50rpx 15rpx 0 0;padding: 30rpx 0;" @click="navTuniaoWebsite">
          <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
            <view class="icon20__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-orangered tn-color-white">
              <view class="tn-icon-computer-fill"></view>
            </view>  
            <view class="tn-text-center" style="font-size: 30rpx;">
              <view class="tn-text-ellipsis">图鸟官网</view>
            </view>
          </view>
        </view>
        <view class="tn-flex-1 about-shadow tn-bg-white" style="margin: 50rpx 0 0 15rpx;padding: 30rpx 0;" @click="navTuniaoUI">
          <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center">
            <view class="icon20__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-purplered tn-color-white">
              <view class="tn-icon-moon-fill"></view>
            </view>  
            <view class="tn-text-center" style="font-size: 30rpx;">
              <view class="tn-text-ellipsis">图鸟UI</view>
            </view>
          </view>
        </view>
      </view> -->

			<!-- 更多信息-->
			<view class="about-shadow tn-margin-top-lg tn-padding-top-sm tn-padding-bottom-sm">
				<tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="30"
					@click="tn('/discoveryPages/myGoodsOrder')">
					<view class="tn-flex tn-flex-col-center">
						<view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
							style="color: #7C8191;">
							<view class="tn-icon-like-fill"></view>
						</view>
						<view class="tn-margin-left-sm tn-flex-1">我的订单</view>
						<view class="tn-color-gray tn-icon-right"></view>
					</view>
				</tn-list-cell>
				
				<tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="30"
					@click="tn('/minePages/nameId')">
					<view class="tn-flex tn-flex-col-center">
						<view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
							style="color: #7C8191;">
							<view class="tn-icon-cardbag-fill"></view>
						</view>
						<view class="tn-margin-left-sm tn-flex-1">实名信息</view>
						<view class="tn-color-gray tn-icon-right"></view>
					</view>
				</tn-list-cell>


				<tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="30" @click="msgClick">
					<button class="tn-flex tn-flex-col-center tn-button--clear-style" >
						<view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
							style="color: #7C8191;">
							<view class="tn-icon-message-fill"></view>
						</view>
						<view class="tn-flex tn-flex-row-between" style="width: 100%;">
							<view class="tn-margin-left-sm">消息订阅</view>
						</view>
					</button>
				</tn-list-cell>
				<tn-list-cell :hover="true" :unlined="true" :radius="true" :fontSize="30">
					<button class="tn-flex tn-flex-col-center tn-button--clear-style" open-type="contact">
						<view class="tn-flex tn-flex-col-center">
							<view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
								style="color: #7C8191;">
								<view class="tn-icon-tel-circle-fill"></view>
							</view>
							<view class="tn-margin-left-sm tn-flex-1">联系客服</view>
						</view>
					</button>
				</tn-list-cell>

			</view>

		</view>

		<!-- 悬浮按钮-->
		<view class="tn-flex tn-footerfixed">
			<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
				<tn-button backgroundColor="red" padding="40rpx 0" width="60%" shadow fontBold @click="loginOut">
					<!-- <text class="tn-icon-light tn-padding-right-xs tn-color-black"></text> -->
					<text class="tn-color-black">退 出 登 录</text>
					<text class="tn-icon-revoke tn-padding-left-xs tn-color-black"></text>
				</tn-button>
			</view>
		</view>
		<view class='tn-tabbar-height'></view>

	</view>
</template>

<script>
	import request from '@/common/request.js';

	export default {
		name: 'Mine',
		data() {
			return {
				user: {},
				listRole: [],
				roleApp: "",
				wallet: {}
			}
		},
		mounted() {
			this.loadData()
		},
		methods: {
			loadData() {
				this.user = uni.getStorageSync("userinfo");
				request.updateUser(this.user.userId);
				this.user = uni.getStorageSync("userinfo");
				request.get("/system/dict/data/list", {
					dictType: 'xxc_role'
				}).then((res) => {
					this.listRole = res.rows;
					for (let i = 0; i < this.listRole.length; i++) {
						if (this.listRole[i].dictValue == this.user.roleApp) {
							this.roleApp = this.listRole[i].dictLabel
						}
					}
				});
				//加载钱包信息
				request.get("/xxc/wallet/info/" + this.user.userId).then((res) => {
					this.wallet = res.data;
				});
			},
			// 跳转到图鸟官网
			navTuniaoWebsite() {
				uni.navigateToMiniProgram({
					appId: 'wxa698b1eee960632f'
				})
			},
			// 跳转到图鸟UI
			navTuniaoUI() {
				uni.navigateToMiniProgram({
					appId: 'wxf3d81a452b88ff4b'
				})
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			// 收货地址
			navAddress() {
				uni.chooseAddress({})
			},
			// 震动跳转
			navThanks(e) {
				wx.vibrateShort();
				uni.navigateTo({
					url: '/minePages/thanks'
				})
			},
			//拨打固定电话
			callPhoneNumber() {
				uni.makePhoneCall({
					phoneNumber: "17714325420",
				});
			},
			// 复制开源地址
			copySource() {
				uni.setClipboardData({
					data: "等待上传插件市场",
				})
			},
			loginOut() {
				uni.showModal({
					title: '提示：',
					content: "确定退出吗？",
					success: function(res) {
						if (res.confirm) {
							request.loginOut();
						}
					}
				});
			},
			msgClick(){
				let that = this;
				if (wx.requestSubscribeMessage) {
				  wx.requestSubscribeMessage({
					tmplIds: ['2oscyU8qAhr4EuZgHbjhummhCOQQULxFaCYvSr1nLmQ','iB4ECIPLRNjUr-SEVHJmf6FVxWCfdl2mU89o9f2lqF4'],
					success(res) {
					  if (res['2oscyU8qAhr4EuZgHbjhummhCOQQULxFaCYvSr1nLmQ','iB4ECIPLRNjUr-SEVHJmf6FVxWCfdl2mU89o9f2lqF4'] === 'accept') {
						// 用户主动点击同意...do something
						wx.showModal({
						  title: '提示',
						  content: '订阅成功!',
						  showCancel: false
						})
					  } else if (res['2oscyU8qAhr4EuZgHbjhummhCOQQULxFaCYvSr1nLmQ','iB4ECIPLRNjUr-SEVHJmf6FVxWCfdl2mU89o9f2lqF4'] === 'reject') {
						// 用户主动点击拒绝...do something
					  } else {
						wx.showToast({
						  title: 'res',
						  icon: 'none'
						})
					  }
					},
					fail(res) {
					  // 20004:用户关闭了主开关，无法进行订阅,引导开启
					  if (res.errCode == 20004) {
						// 显示引导设置弹窗
						that.setData({
						  isShowSetModel: true
						})
					  }else{
						// 其他错误信息码，对应文档找出原因
						wx.showModal({
						  title: '提示',
						  content: res.errMsg,
						  showCancel: false
						})
					  }
					}
				  });
				} else {
				  wx.showModal({
					title: '提示',
					content: '请更新您微信版本，来获取订阅消息功能',
					showCancel: false
				  })
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mine {
		max-height: 100vh;
	}

	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 120rpx;
		height: calc(140rpx + env(safe-area-inset-bottom) / 2);
		height: calc(140rpx + constant(safe-area-inset-bottom));
	}

	.tn-color-cat {
		color: #1D2541;
	}

	.tn-bg-cat {
		background-color: #1D2541;
	}


	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 5rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			flex-basis: 5%;
			width: 100rpx;
			position: absolute;
		}
	}

	/* 自定义导航栏内容 end */


	/* 顶部背景图 end */

	/* 搜索 start */
	.shaixuan {
		width: 110rpx;
		height: 110rpx;
		position: relative;
		overflow: hidden;
	}

	/* 用户头像 start */
	.logo-image {
		width: 110rpx;
		height: 110rpx;
		position: relative;
		overflow: hidden;
		border-radius: 50%;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border: 8rpx solid rgba(255, 255, 255, 0.05);
		box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
		border-radius: 50%;
		overflow: hidden;
		// background-color: #FFFFFF;
	}

	/* 页面 start*/
	.about-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.about {

		&__wrap {
			position: relative;
			z-index: 1;
			margin: 20rpx 30rpx;
		}
	}

	/* 页面 end*/

	/* 图标容器15 start */
	.icon15 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;


				}
			}
		}
	}

	/* 图标容器12 start */
	.tn-three {
		position: absolute;
		top: 50%;
		right: 50%;
		bottom: 50%;
		left: 50%;
		transform: translate(-38rpx, -16rpx) rotateX(30deg) rotateY(20deg) rotateZ(-30deg);
		text-shadow: -1rpx 2rpx 0 #f0f0f0, -2rpx 4rpx 0 #f0f0f0, -10rpx 20rpx 30rpx rgba(0, 0, 0, 0.2);
	}

	.icon20 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 100rpx;
				height: 100rpx;
				font-size: 60rpx;
				border-radius: 50%;
				margin-bottom: 18rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);
				}
			}
		}
	}



	.button-vip {
		width: 100%;
		height: 150rpx;
		border-radius: 15rpx;
		position: relative;
		z-index: 1;

		&::after {
			content: " ";
			position: absolute;
			z-index: -1;
			width: 100%;
			height: 100%;
			left: 0;
			bottom: 0;
			border-radius: inherit;
			opacity: 1;
			transform: scale(1, 1);
			background-size: 100% 100%;
			background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);
		}
	}


	/* 图标容器12 start */
	.icon12 {
		&__item {
			width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 15rpx;
				height: 15rpx;
				font-size: 50rpx;
				border-radius: 50%;
				margin-bottom: 38rpx;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;

				}
			}
		}
	}

	/* 图标容器1 start */
	.icon1 {
		&__item {
			// width: 30%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			padding: 30rpx;
			margin: 20rpx 10rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 40rpx;
				height: 40rpx;
				font-size: 40rpx;
				border-radius: 50%;
				position: relative;
				z-index: 1;

				&::after {
					content: " ";
					position: absolute;
					z-index: -1;
					width: 100%;
					height: 100%;
					left: 0;
					bottom: 0;
					border-radius: inherit;
					opacity: 1;
					transform: scale(1, 1);
					background-size: 100% 100%;
					background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg.png);
				}
			}
		}
	}

	/* 图标容器1 end */


	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;

		.backgroud-image {
			width: 100%;
			height: 450rpx;
			// z-index: -1;
		}
	}

	/* 顶部背景图 end */
</style>